from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
import os

# 初始化模型
model = ChatOpenAI(model="gpt-3.5-turbo")

# 创建提示词模板
prompt = ChatPromptTemplate.from_messages(
    [("system", "你是一个有帮助的助手"), ("human", "{user_input}")]
)

# 构建链
chain = prompt | model

# 执行对话
response = chain.invoke({"user_input": "请介绍一下人工智能"})
print(response.content)
